package com.erp.common;

import java.util.HashMap;
import java.util.Map;

class Test {
    public int[] remove(int number,int[] array){
        if (number==0){
            return array;
        }
        for (int i = 0;i < number;i++){
            for (int j=i+1;j<number;j++){
                if (array[i]%2!=array[j]%2){
                    int a = Integer.parseInt(array[i]+""+array[j]);
                    int b = Integer.parseInt(array[j]+""+array[i]);
                    if (a>b){
                        int tmp = array[i];
                        array[i] = array[j];
                        array[j]=tmp;
                    }
                }
            }
        }
        return array;
    }

    public int select(int length,int k,String string){
        Map<Integer,Integer> map = new HashMap<>();
        map.put(0,1);
        int sum = 0,ans = 0;
        for (char c : string.toCharArray()) {
            System.out.println(c);
            sum+=c;
            int modulus = (sum % k + k ) % k;
            map.put(modulus,map.getOrDefault(modulus,0)+1);
        }
        for (Map.Entry<Integer,Integer>entry : map.entrySet()){
            ans+=entry.getValue()*(entry.getValue()-1);
        }
        return ans-1;
    }

    public static void main(String[] args) {
        Test test = new Test();
        int[] array = {10,8,2};
        for (int i : test.remove(3, array)) {
            System.out.println(i);
        }
        int select = test.select(4, 3, "1422");
        System.out.println(select);

    }
}
